import {
	onMounted,
	watch
} from 'vue'
import {
	useStore
} from "@/stores/user.js"

export function usePermissionDirective(app) {
	app.directive('auth', {
		mounted(el, binding) {
			const userStore = useStore()
			const {
				value
			} = binding
			if (!value) {
				return
			}
			const permission = userStore.userInfo.role
			// //超管包含所有
			if (permission === 1) {
				return  
			}
			if (!value.includes(permission)) {
				el.parentNode && el.parentNode.removeChild(el)
			}
		},
	})
}